﻿(function (app) {
    app.config(["$stateProvider", "$urlRouterProvider", function ($stateProvider, $urlRouterProvider) {
        $stateProvider
          .state('login', {
              url: '/account/login',
              templateUrl: 'templates/account/login.html',
              controller: 'loginCtrl'
          })
         .state('register', {
             url: '/account/register',
             templateUrl: 'templates/account/register.html',
             controller: 'registerCtrl'
         })
        .state('forgetPassword', {
            url: '/account/forgetPassword',
            templateUrl: 'templates/account/forgetpassword.html',
            controller: 'forgetPasswordCtrl'
        })
          .state('app', {
              url: '/app',
              abstract: true,
              templateUrl: "templates/tabs.html",
              controller: 'tabsCtrl'
          })
        .state('app.home', {
            url: '/home',
            views: {
                'app-borrow': {
                    templateUrl: 'templates/home/index.html',
                    controller: 'homeCtrl'
                }
            }
        })
        
        .state('app.my', {
            url: '/my',
            views: {
                'app-my': {
                    templateUrl: 'templates/my/index.html',
                    controller: 'myCtrl'
                }
            }
        })

        if (localStorage['token']) {
            $urlRouterProvider.otherwise('/app/home');
        } else {
            $urlRouterProvider.otherwise('/account/login');
        }

    }]);
})(angular.module('app'));